package com.xin.ruanjian.omsystem.fragment;

import android.os.Bundle;
import android.support.annotation.Nullable;
import android.text.TextUtils;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import com.xin.ruanjian.omsystem.R;
import com.xin.ruanjian.omsystem.bases.BaseFragment;
import com.xin.ruanjian.omsystem.bean.IndexBean.MsgBean.ShopBean;
import com.xin.ruanjian.omsystem.utils.GlideUtils;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;
import butterknife.Unbinder;

/**
 * Created by local123 on 2018/2/20.
 */

public class ShopInfoFragment extends BaseFragment {
    @BindView(R.id.iv_shop_head)
    ImageView ivShopHead;
    @BindView(R.id.tv_shop_name)
    TextView tvShopName;
    @BindView(R.id.tv_shop_phone)
    TextView tvShopPhone;
    @BindView(R.id.tv_shop_address)
    TextView tvShopAddress;
    @BindView(R.id.tv_shop_time)
    TextView tvShopTime;
    Unbinder unbinder;
    @BindView(R.id.tv_shop_content)
    TextView tvShopContent;
    Unbinder unbinder1;
    private ShopBean shopBean;

    public static ShopInfoFragment newInstance(ShopBean shopBean) {
        ShopInfoFragment fragment = new ShopInfoFragment();
        Bundle bundle = new Bundle();
        bundle.putSerializable("shop_info", shopBean);
        fragment.setArguments(bundle);
        return fragment;
    }

    @Override
    protected View initContentView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        return inflater.inflate(R.layout.fragment_shop_info, container, false);
    }

    @Override
    protected void initView(View view) {

    }

    @Override
    protected void initData() {
        shopBean = (ShopBean) getArguments().getSerializable("shop_info");
        tvShopName.setText(shopBean.getShopname());
        tvShopAddress.setText(shopBean.getProvince() + shopBean.getCity() + shopBean.getCounty() + shopBean.getAddress());
        tvShopPhone.setText(shopBean.getShopphone());
        if (TextUtils.isEmpty(shopBean.getContent())) {
            tvShopContent.setVisibility(View.GONE);
        } else {
            tvShopContent.setVisibility(View.VISIBLE);
            tvShopContent.setText(shopBean.getContent());
        }
        GlideUtils.glideLoader(context, shopBean.getShophead(), ivShopHead, GlideUtils.Shape.CIRCLE);
    }

    @OnClick({R.id.tv_shop_phone, R.id.tv_shop_address, R.id.tv_shop_time})
    public void onViewClicked(View view) {
        switch (view.getId()) {
            case R.id.tv_shop_phone:
                break;
            case R.id.tv_shop_address:
                break;
            case R.id.tv_shop_time:
                break;
        }
    }
}
